package net.neptech.controller;

import net.neptech.model.information.InforNews;
import net.neptech.service.InforNewsService;
import net.neptech.vm.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author 谢辉
 * @Date 2025/8/21 11:37
 * @Description 医疗新闻表
 **/

@RestController
@RequestMapping("/information/inforNews")
public class InforNewsController {

    @Autowired
    InforNewsService inforNewsService;

    /**
     * 增加医疗新闻
     */
    @PostMapping("/addInforNews")
    public ResponseResult addInforNews(@RequestBody InforNews inforNews) {
        inforNewsService.addInforNews(inforNews);
        return ResponseResult.success();
    }

    /**
     * 删除医疗新闻
     */
    @DeleteMapping("/{id}")
    public ResponseResult deleteInforNews(@PathVariable("id") Long id) {
        inforNewsService.deleteInforNews(id);
        return ResponseResult.success();
    }

    /**
     * 查询全部医疗新闻
     */
    @GetMapping()
    public ResponseResult findInforNews() {
        return ResponseResult.success(inforNewsService.findInforNews());
    }

    /**
     * 修改医疗新闻
     */
    @PutMapping("/updateInforNews")
    public ResponseResult updateInforNews(@RequestBody InforNews inforNews) {
        inforNewsService.updateInforNews(inforNews);
        return ResponseResult.success();
    }

    /**
     * 根据id查询医疗新闻
     */
    @GetMapping("/{id}")
    public ResponseResult findInforNewsById(@PathVariable("id") Long id) {
        return ResponseResult.success(inforNewsService.findInforNewsById(id));
    }
}
